﻿@model  P2PWeb.Models.Pager<P2PWeb.Models.Campaign>
@using P2PWeb.Controllers;
@using P2PWeb.Common
@using P2PWeb;

<table>
    <tr>
        <td>借款单状态:</td>
        <td>
            @Html.CheckBox("borrowStateValues", ((int[])ViewData["borrowStateValues"]).Contains(-1), new {value=-1 })
            @Html.Label("所有状态")

            @foreach (CampaignState campaignState in Enum.GetValues(typeof(CampaignState)))
            {
                @Html.CheckBox("borrowStateValues", ((int[])ViewData["borrowStateValues"]).Contains((int)campaignState),new {value=(int)campaignState })
                @Html.Label(campaignState.GetDisplayName())
            }
        </td>
        <td><a id="searchBtn">查询</a></td>
    </tr>
</table>

<table cellpadding="0" cellspacing="0" width="100%">
    <tbody>
        <tr class="total_th">
            <th class="name">借款单号</th>
            <th>借款金额</th>
            <th>下单时间</th>
            <th>到期日期</th>
            <th>订单状态</th>
            <th class="last_th">操作</th>
        </tr>
        <tr class="">
            <th colspan="6">&nbsp;</th>
        </tr>

        @foreach (P2PWeb.Models.Campaign campaign in Model.Items)
        {
            <tr class="first_td">
                @if(campaign.Mortgage==4){
                   <td class="left_td"><a href="/Lenders/Project?id=@campaign.ID">@campaign.ID</a>
                </td>
                }else{
                  <td class="left_td"><a href="/Lenders/LendrsDetail?id=@campaign.ID">@campaign.ID</a>
                  </td>
                }               
                <td>@campaign.Amount.ToString("N2") 元</td>
                <td>@campaign.CreationTime.Value.ToString("yyyy年MM月dd日 hh时 mm分")</td>
                <td>@(campaign.DueDate.GetValueOrDefault().ToString("yyyy年MM月dd日"))
                </td>
                <td class="red">@(((P2PWeb.Common.CampaignState)campaign.Status).GetDisplayName())</td>
                <td>
                    @if (campaign.Status == (int)CampaignState.Draft)
                    {
                        ContentResult result = null;
                        if (!P2PWeb.Controllers.BorrowStep1Controller.CheckMortgageAttachment(campaign, (ViewData["curAccount"] as P2PWeb.Models.Account),
                            out result))
                        {
                        @Html.ActionLink("充值", "/chongzhi");
                        }
                        else
                        {
                        @Html.ActionLink("上传抵押证明", "NavToUploadifyMortgage", "borrowStep1", new { borrowId = campaign.ID }, null)
                        }
                    }
                </td>
            </tr>
        }
    </tbody>
</table>

<div id="navDiv" class="loan_page">

    <script>
        $(document).ready(function () {
            $('#searchBtn').click(function(){
                var borrowStateValues=[];
                $(":checkbox[name=borrowStateValues]:checked").each(function(){
                    borrowStateValues.push($(this).val());
                });

                var borrowStateValuesJson={};
                for(var index in borrowStateValues)
                {
                    borrowStateValuesJson[index]=borrowStateValues[index];
                }

                NavToPage(1,"myborrows","#borrowsContainer",{BorrowStateValues:borrowStateValuesJson})
            });

            var currentborrowStateValues= [];
            $(":checkbox[name=borrowStateValues]:checked").each(function(){
                currentborrowStateValues.push($(this).val());
            });

            var currentborrowStateValuesJson={};
            for(var index in currentborrowStateValues)
            {
                currentborrowStateValuesJson[index]=currentborrowStateValues[index];
            }

            MakerNavs('myborrows','index',@Model.CurrentPageIndex,@Model.TotialPaqgerCount,@Model.Items.Count,@Model.TotialItemsCount,'navDiv','borrowsContainer',{BorrowStateValues:currentborrowStateValuesJson});
        });
    </script>
</div>

